package com.clqteam.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.clqteam.model.Role;
import com.clqteam.service.ShowrNameService;
import com.clqteam.serviceimpl.ShowrNameServiceImpl;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
 * 
 * @author CLQ
 *
 */
public class ShowrNameUpController extends HttpServlet {
	   
	ShowrNameService rNameUp=new ShowrNameServiceImpl();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	req.setCharacterEncoding("utf8");
    resp.setCharacterEncoding("utf8");
    List<Role> rname= rNameUp.findrNameByEmployee();
     JSONArray js=new JSONArray();
     for ( Role rName :rname) {
   	  JSONObject j=new JSONObject();
   	  j.put("rtext1", rName.getrName());
   	  j.put("rid1", rName.getrId());
   	  js.add(j);
	   }
       PrintWriter pw=resp.getWriter();
       pw.write(js.toString());
       pw.flush();
       pw.close();
	}
}
